home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / pascal / psgui130.zip / PGUI-EG.PAS < prev    next >
Pascal/Delphi Source File  |  1993-01-01  |  10KB  |  338 lines

  1. {
  2.  
  3.                                                       ╔══════════════════╗
  4.                                                       ║      PGUI        ║
  5.                                                       ║     Example      ║
  6.                                                       ║    Rev. 1.01     ║
  7.                                                       ╚══════════════════╝
  8.  
  9. }
  10.  
  11. Program EG;
  12.  
  13. {$F-} {$O-} {$A+} {$G-}
  14. {$V-} {$B-} {$X-} {$N+} {$E+}
  15.  
  16. {$I FINAL.PAS}
  17.  
  18. {$IFDEF FINAL}
  19.   {$I-} {$R-}
  20.   {$D-} {$L-} {$S-}
  21.   {$M 8192,262144,655360}
  22. {$ELSE}
  23.   {$M 8192,0,655360}
  24. {$ENDIF}
  25.  
  26. {$M 20000,120000,300000}
  27.  
  28. Uses CRT,Dos,Graph,PGUI,Strings,Dirs;
  29.  
  30. { ╔════════════════════════════════════════════════════════════════════════╗ }
  31. { ║                                                                        ║ }
  32. { ║  This program is an example for the Pure Power GUI.                    ║ }
  33. { ║                                                                        ║ }
  34. { ║  Program Author : Michael Gallias                                      ║ }
  35. { ║  Date           : 31 January  1992                                     ║ }
  36. { ║  Last Updated   : 31 December 1992                                     ║ }
  37. { ║                                                                        ║ }
  38. { ╚════════════════════════════════════════════════════════════════════════╝ }
  39.  
  40. Var
  41.   Ver  :String[10];
  42.   FName:PathStr;
  43.  
  44. Procedure QuitProg;
  45.  
  46. { ╔════════════════════════════════════════════════════════════════════════╗ }
  47. { ║                 Quit Program                                           ║ }
  48. { ╚════════════════════════════════════════════════════════════════════════╝ }
  49.  
  50. Begin
  51.   CloseGraph;
  52.   WriteLn('Thank you,');
  53.   WriteLn('  for using the Pure Power GUI Unit by Michael Gallias.');
  54.   Halt(0);
  55. End;
  56.  
  57. Function SureQuit:Boolean;
  58.  
  59. { ╔════════════════════════════════════════════════════════════════════════╗ }
  60. { ║               Prompt Before Quit                                       ║ }
  61. { ╚════════════════════════════════════════════════════════════════════════╝ }
  62.  
  63. Var
  64.   PWin     :GraphicWindow;
  65.   X,Y      :Word;
  66.   MB       :Byte;
  67.   Held,
  68.   Doubled,
  69.   Special  :Boolean;
  70.   Key      :Char;
  71.  
  72. Begin
  73.   PWin.Open(100,100,280,200,Red,Black,2,SolidFill,Black,True);
  74.   PWin.NewHeading('Quit',CentreText,Yellow,CloseDotFill,Blue);
  75.   Mouse.Hide;
  76.   PWin.Lock;
  77.   SetColor(White);
  78.   OutTextXY(40,30,'Are you sure?');
  79.   PWin.UnLock;
  80.   PWin.Buttons.Create(145,150,180,180,2,Black,NIL,'Yes',False,'Y');
  81.   PWin.Buttons.Create(195,150,230,180,2,Black,NIL,'No',False,'N');
  82.   Mouse.Show;
  83.   PWin.Buttons.WaitForClick(X,Y,MB,Held,Doubled,Special,Key);
  84.   If (Key='Y') And (Not Special) Then SureQuit:=True Else SureQuit:=False;
  85.   PWin.Close;
  86. End;
  87.  
  88. Procedure NewName(Var FName:String);
  89.  
  90. { ╔════════════════════════════════════════════════════════════════════════╗ }
  91. { ║    Gets a New File Name when a directory is being displayed            ║ }
  92. { ╚════════════════════════════════════════════════════════════════════════╝ }
  93.  
  94. Var
  95.    Temp   :String;
  96.  
  97.    PWin   :GraphicWindow;
  98.    X,Y    :Word;
  99.    MB     :Byte;
  100.    Held,
  101.    Doubled,
  102.    Special:Boolean;
  103.    Key    :Char;
  104.  
  105. Begin
  106.   PWin.Open(75,200,575,320,Red,Black,2,SolidFill,Black,True);
  107.   PWin.NewHeading('New File Name',CentreText,Yellow,CloseDotFill,Blue);
  108.   Mouse.Hide;
  109.   SetColor(White);
  110.   PWin.Lock;
  111.   OutTextXY(30,30,'Specify the file name, including path if needed.');
  112.   OutTextXY(30,90,'Press [Esc] to Abort');
  113.   Temp:='';
  114.   EditString(30,60,40,True,Temp);
  115.   PWin.UnLock;
  116.   Mouse.Show;
  117.   If Temp<>'' Then FName:=Temp;
  118.   PWin.Close;
  119. End;
  120.  
  121. Procedure NewPath;
  122.  
  123. { ╔════════════════════════════════════════════════════════════════════════╗ }
  124. { ║   Lets the user specify a new directory to search.                     ║ }
  125. { ╚════════════════════════════════════════════════════════════════════════╝ }
  126.  
  127. Var
  128.    Temp:String;
  129.  
  130.    PWin   :GraphicWindow;
  131.    X,Y    :Word;
  132.    MB     :Byte;
  133.    Held,
  134.    Doubled,
  135.    Special:Boolean;
  136.    Key    :Char;
  137.  
  138. Begin
  139.   PWin.Open(75,200,575,320,Red,Black,2,SolidFill,Black,True);
  140.   PWin.NewHeading('New Path',CentreText,Green,CloseDotFill,Blue);
  141.   Mouse.Hide;
  142.   PWin.Lock;
  143.   SetColor(White);
  144.   OutTextXY(30,30,'Specify the path name, drive letter included if needed.');
  145.   OutTextXY(30,90,'Press [Esc] to Abort');
  146.   Temp:='';
  147.   EditString(30,60,40,True,Temp);
  148.   PWin.UnLock;
  149.   Mouse.Show;
  150.   If Temp<>'' Then GoDir(Temp);
  151.   PWin.Close;
  152. End;
  153.  
  154. Procedure OneFile(Var FName:String);
  155.  
  156. { ╔════════════════════════════════════════════════════════════════════════╗ }
  157. { ║  Lets the user pick one file from the files on the disk.               ║ }
  158. { ╚════════════════════════════════════════════════════════════════════════╝ }
  159.  
  160. Const
  161.    X = 200;    {Area to display the}
  162.    Y = 120;    {list of files}
  163.  
  164. Var
  165.    PWin   :GraphicWindow;
  166.    MX,MY  :Word;
  167.    MB     :Byte;
  168.    PgUp,
  169.    PgDn,
  170.    Held,
  171.    Doubled,
  172.    Special:Boolean;
  173.    Key    :Char;
  174.  
  175.    Dir     :DirList;
  176.    NewDir,
  177.    Okay    :Boolean;
  178.    EndF,
  179.    I,J,
  180.    Current,
  181.    Start   :Word;
  182.    Mask    :String[64];
  183.  
  184.    MouseDef:BGIMouseShapePtr;
  185.  
  186. Begin
  187.   Dir.Root:=NIL;
  188.   Dir.Info:=NIL;
  189.   Dir.Total:=0;
  190.   StandardScreen('PGUI Unit Example Program   (c)  Michael Gallias  1993   '+Ver);
  191.   PWin.Open(50,50,590,440,Blue,Black,4,SolidFill,Black,False);
  192.   PWin.NewHeading('Select A File',CentreText,Yellow,CloseDotFill,LightGray);
  193.  
  194.   New(MouseDef);
  195.  
  196.   NewDir:=False;
  197.   Repeat {Not NewDir}
  198.     MouseDef^.Picture:=IconBGIMouseCursorA;
  199.     MouseDef^.Mask   :=IconBGIMouseMaskA;
  200.     MouseDef^.XHot   :=0;
  201.     MouseDef^.YHot   :=0;
  202.     Mouse.SetShape(MouseDef);
  203.  
  204.     Okay:=False;
  205.     Mask:='*.*';
  206.     LoadDirList(Dir,Mask,StdFile,Directories + Files);
  207.     Start:=1;
  208.     Current:=1;
  209.  
  210.     MouseDef^.Picture:=IconBGIMouseCursorC;
  211.     MouseDef^.Mask   :=IconBGIMouseMaskC;
  212.     MouseDef^.XHot   :=0;
  213.     MouseDef^.YHot   :=0;
  214.     Mouse.SetShape(MouseDef);
  215.  
  216.     Repeat    {Okay}
  217.       Mouse.Hide;
  218.       SetFillStyle(SolidFill,Black);
  219.       Bar(X,Y-40,X+200,Y+295);
  220.       Mouse.Show;
  221.       ShowDirList(Dir,Files + Directories + Size, X, Y,
  222.                   Current, Start, 21, Green, Blue, White, PgUp, PgDn);
  223.  
  224.       PWin.Buttons.Add(9999,9999,9999,9999,0,0,NIL,'',True,'H');
  225.       {Up Key, Keyboard Only}
  226.       PWin.Buttons.Add(9999,9999,9999,9999,0,0,NIL,'',True,'P');
  227.       {Down Key, Keyboard Only}
  228.  
  229.       If PgUp Then
  230.         PWin.Buttons.Create(X+60,Y-40,X+100,Y-15,2,Black,NIL,'PgUp',True,'I');
  231.  
  232.       If PgDn Then
  233.         PWin.Buttons.Create(X+60,Y+270,X+100,Y+295,2,Black,NIL,'PgDn',True,'Q');
  234.  
  235.       I:=0;
  236.       J:=1;
  237.       If Dir.Total>0 Then
  238.         Repeat
  239.           PWin.Buttons.Add(X-5,Y+I,X+100,Y+I+8,0,0,NIL,'',False,Chr(J));
  240.           Inc(I,12);
  241.           Inc(J);
  242.         Until J=Dir.Total+1                            {Up to 21 Files}
  243.       Else
  244.         OutTextXY(X+16,Y+30,'No Files');
  245.  
  246.       PWin.Buttons.Create(80,210,140,255,2,Black,NIL,'Okay',False,'O');
  247.       PWin.Buttons.Create(440,210,500,255,2,Black,NIL,'Path',False,'P');
  248.       PWin.Buttons.Create(440,270,500,315,2,Black,NIL,'Name',False,'N');
  249.       PWin.Buttons.Create(576,1,634,15,2,Black,NIL,'Quit',False,#27);
  250.  
  251.       PWin.Buttons.WaitForClick(MX,MY,MB,Held,Doubled,Special,Key);
  252.       SetColor(White);
  253.       If Special Then
  254.       Begin
  255.         Case Key Of
  256.           'I':Begin
  257.                 If Start>20 Then Dec(Start,20) Else Start:=1;
  258.                 Current:=Start;
  259.               End;
  260.           'Q':Begin
  261.                 Inc(Start,20);
  262.                 If Dir.Total-Start<21 Then Start:=Dir.Total-20;
  263.                 Current:=Start;
  264.               End;
  265.           'H':Begin
  266.                 If Current>1 Then Dec(Current);
  267.                 If Current<Start Then Dec(Start);
  268.               End;
  269.           'P':Begin
  270.                 If Current<Dir.Total Then Inc(Current);
  271.                 If (Current>Start+20) And (Start+20<Dir.Total) Then Inc(Start);
  272.               End;
  273.         End;
  274.       End
  275.       Else
  276.         Case Key Of
  277.           'O':Begin
  278.